package com.atguigu.dga.governance.task;

import com.atguigu.dga.governance.service.GovernanceAssessDetailService;
import com.atguigu.dga.meta.service.TableMetaInfoService;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class AssessScheduleTask {

    @Autowired
    TableMetaInfoService tableMetaInfoService;

    @Value("${assess.schemas}")
    String schemaName;

    @Autowired
    GovernanceAssessDetailService governanceAssessDetailService;


    @Scheduled(cron = "0 38 10 * * *")
    public void assess(){
//        String assessDate = DateFormatUtils.format(new Date(), "yyyy-MM-dd");
        for (String schema : schemaName.split(",")) {

            tableMetaInfoService.initMetaInfo("2023-05-01",schema);
        }
        governanceAssessDetailService.mainAssess("2023-05-01");

    }
}
